FROM node:alpine as builder
ENV PROJECT_ENV production
RUN yarn config set registry https://registry.npm.taobao.org/ && yarn global add @vue/cli@4.1.1
# build front end
WORKDIR /build/paper-system
# ADD paper-system/package.json /build/paper-system
ADD ./paper-system /build/paper-system
ADD ./nginx_fe.conf /build
RUN yarn install && yarn run build
# build admin front end
WORKDIR /build/paper-system-admin
# ADD paper-system-admin/package.json /build/paper-system-admin
ADD ./paper-system-admin /build/paper-system-admin
ADD ./nginx_admin_fe.conf /build
RUN yarn install && yarn run build
ADD ./nginx.conf /build

FROM nginx:alpine
RUN rm -rf /etc/nginx/conf.d/default.conf
# copy dist to nginx dir
COPY --from=builder /build/paper-system/dist /usr/share/nginx/html/paper-system/fe
COPY --from=builder /build/paper-system-admin/dist /usr/share/nginx/html/paper-system/admin-fe
# copy nginx website config to conf.d
COPY --from=builder /build/nginx_fe.conf /etc/nginx/conf.d/nginx_fe.conf
COPY --from=builder /build/nginx_admin_fe.conf /etc/nginx/conf.d/nginx_admin_fe.conf
# copy nginx.conf
COPY --from=builder /build/nginx.conf /etc/nginx/nginx.conf 